from flask import g, Blueprint, request
from app.api import handle_error
from app.common.result import trueReturn, falseReturn

alert_blueprint = Blueprint('alert_blueprint', __name__, url_prefix='/alert')


# @socket_io.on('connect')
# def connect():
#     print(request.sid)
#     pass


@alert_blueprint.before_request
@handle_error
def before_request():
    if (request.method == 'POST' or request.method == 'PUT') and request.get_data():
        g.data = request.get_json()
    elif request.method == 'GET' or request.method == 'DELETE':
        g.data = request.args
    else:
        g.data = {}
